home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / SLTPU70C / MODEM.DOC < prev    next >
Text File  |  1993-03-21  |  14KB  |  316 lines

  1.  
  2. ------------------------------------------------------------------------
  3. Searchlight Modem Interface Unit              v3.0           March 1993
  4. ------------------------------------------------------------------------
  5.  
  6. Updates
  7. Searchlight 3.0 adds several new functions to the modem driver unit. See
  8. the end of this document for details.
  9.  
  10.  
  11. Introduction
  12.  
  13. This unit provides functions which enable a Door program running under 
  14. Searchlight BBS (version 2.15C or later) to access Searchlight's serial port 
  15. drivers directly. While Searchlight supports Door programs indirectly via 
  16. the BIOS level output redirection, the functions provided here are important 
  17. if you wish to perform operations such as:
  18.  
  19.    ■ Output characters directly to the modem without displaying on the
  20.      local screen
  21.    ■ Output control characters or ANSI sequences directly to the modem
  22.    ■ Control the modem input and output buffers
  23.    ■ Perform your own carrier detection
  24.    ■ Hang up on the remote user
  25.  
  26. The modem functions in this unit can be used in two ways. If your door 
  27. program is run with Searchlight BIOS modem redirection active (that is, in 
  28. "Standard" or "Force-Color" mode), you can perform the majority of your 
  29. input and output via standard read and write functions which access the 
  30. BIOS, supplementing these with function calls when a special feature such as 
  31. carrier detection, or hanging up the modem, is required. Alternately, if 
  32. your DOOR program runs with BIOS redirection disabled ("None" mode), you can 
  33. do all of your modem i/o directly through the function calls. For the vast 
  34. majority of programs, the first method is preferable, since it does not 
  35. require major changes to your source code.
  36.  
  37. Because these function calls use Searchlight's drivers directly, there is no 
  38. need to write modem control functions in your application and no need to do 
  39. any kind of direct hardware addressing. In addition, if Searchlight BBS is 
  40. configured to use a FOSSIL driver or a Digiboard, all of the function calls 
  41. in this unit will automatically be routed to the FOSSIL driver or Digiboard 
  42. driver in use. Thus, your program is assured of running correctly on any 
  43. properly configured Searchlight BBS installation, regardless of the serial 
  44. port configuration.  
  45.  
  46. Note that although a Turbo Pascal source file is included, most functions 
  47. resolve to straight 8086 interrupt calls. This means that the functions are 
  48. readily translated to C or assembly language.
  49.  
  50. The Pascal unit also includes a data definition to the Searchlight "public" 
  51. data area and a public data area pointer; these features have been 
  52. documented previously, and will be briefly covered again here.
  53.  
  54.  
  55.  
  56. Functions, Variables & Type Definitions
  57.  
  58.  
  59. Var DriverLoaded: boolean;             { Set if SLBBS drivers available }
  60.  
  61. This global variable is set automatically by the MODEM unit's initialization 
  62. code. It is set to TRUE if Searchlight modem drivers are available, FALSE 
  63. otherwise. A FALSE setting indicates that Searchlight is not loaded into 
  64. memory (ie. your program was not run as a door) or that the version of 
  65. Searchlight in memory is older than 2.15C. Modem control functions cannot be 
  66. used if this variable is FALSE.
  67.  
  68.  
  69. Function CarrierDetect: boolean;       { Check carrier status }
  70.  
  71. This function checks the carrier detect signal on the modem. TRUE is 
  72. returned if carrier is detected, FALSE otherwise.
  73.  
  74.  
  75. Procedure Hangup;                      { Disconnect (hangup) }
  76.  
  77. This procedure causes the modem to disconnect or hang up on the remote 
  78. caller. It's a good idea to call the WaitOut function before hanging up, to 
  79. assure that all pending output is sent.  
  80.  
  81. Example:   WaitOut;
  82.            Hangup;
  83.  
  84. Note: Your program should terminate IMMEDIATELY after calling Hangup, and 
  85. control MUST return directly to Searchlight BBS so that it may recycle 
  86. properly. Hangup should be used ONLY if your program executes directly from 
  87. Searchlight as an EXE file. Don't use this function if your program will run 
  88. from a batch file!  
  89.  
  90.  
  91. Function RS232Avail: boolean;         { Check RS232 char available }
  92.  
  93. This function returns TRUE if there is a character available to be read from 
  94. the modem input buffer.
  95.  
  96.  
  97. Function RS232In: char;                { Read RS232 char }
  98.  
  99. This function reads a character from the modem input buffer. You should only 
  100. call RS232In if RS232Avail is TRUE.
  101.  
  102. Example:   If RS232Avail then c:=RS232In;   { c = char }
  103.  
  104.  
  105. Procedure RS232Out (c: char);          { Write RS232 char }
  106.  
  107. Sends a character to the modem. You can send any ASCII character from 0 to 
  108. 255. The character is sent directly to the modem without translation.
  109.  
  110. Example:   RS232Out(#27);   { Send clear screen sequence-- ESC[2J }
  111.            RS232Out('[');
  112.            RS232Out('2');
  113.            RS232Out('J');
  114.  
  115.  
  116. Procedure PauseOutput;                 { Pause buffered output }
  117. Procedure RestartOutput;               { Restart output after pause }
  118.  
  119. If output buffering is active, these function calls allow you to pause and 
  120. restart the output to the modem. They have no effect if there is no output
  121. buffering. Note: if a FOSSIL driver is used, these functions may or may not
  122. work, depending on whether the FOSSIL driver implements them.
  123.  
  124.  
  125. Procedure ClearInputBuffer;            { Clear input buffer }
  126. Procedure ClearOutputBuffer;           { Clear output buffer }
  127.  
  128. These procedures clear the contents of the input buffer and output buffer, 
  129. respectively. Clearing the input buffer destroys any waiting input 
  130. characters; clearing the output buffer discards any characters which were 
  131. output but which have not yet been transmitted. As with PausOutput and 
  132. RestartOutput, the success of these functions when a FOSSIL driver is in use 
  133. will depend on the FOSSIL driver's implementation.
  134.  
  135.  
  136. Function BufferEmpty: boolean;         { Check if output buffer empty }
  137.  
  138. This function returns TRUE if the output buffer is empty (or if there is no 
  139. output buffering). It returns FALSE if there are characters in the output 
  140. buffer. A FALSE result means that not all characters which were printed have 
  141. been transmitted to the remote terminal.
  142.  
  143.  
  144. Procedure WaitOut;                     { Wait for output buffer to clear }
  145.  
  146. This procedure waits for the output buffer to clear, and returns when all 
  147. characters have been transmitted. It has no effect if the output buffer is 
  148. already empty or if no buffering is enabled. It is better to call this 
  149. function rather than test the BufferEmpty condition in a loop, since this 
  150. function is optimized for use in multitasking environments.
  151.  
  152. Example:   If (not Bufferempty) then WaitOut;
  153.  
  154.  
  155. Var AUXIn: text;                       { RS232 Input File }
  156.     AUXOut: text;                      { RS232 Output File }
  157.  
  158. These text file handlers can be used instead of the RS232In and RS232Out 
  159. procedures to provide input and output to the modem. Since they are text
  160. files, you can use them in standard Pascal read and write statements.
  161.  
  162. Example:   Write(Auxout,#27'[2J');  { Send clear sequence. This has the same
  163.                                       effect as the RS232Out example. } 
  164.  
  165.  
  166. Procedure ComToggle;                   { Toggle BIOS I/O support on and off }
  167.  
  168. This function toggles the BIOS redirection feature (ie. the function which 
  169. directs standard output and input through the modem) on and off. You should 
  170. only use this function if BIOS redirection is enabled when your program 
  171. begins (ie. if your program is run as a "Standard" or "Force-Color" type 
  172. door). ComToggle can be used whenever you wish to write text to the local 
  173. screen only.
  174.  
  175. Example:   Write('This message appears on both the local and remote screen.');
  176.            ComToggle;
  177.            Write('This message appears only on the local screen.');
  178.            ComToggle;
  179.            Write('This message again appears on both screens.');
  180.  
  181. You should also call ComToggle before executing any program that does its 
  182. own modem input and output-- for example, before calling a protocol engine 
  183. to perform an upload or download. Be sure that you toggle the com support 
  184. back on before your program exits.
  185.  
  186.  
  187. type RSbaud = (B110,B150,B300,B600,B1200,B2400,B4800,B9600,B19200,B38400,
  188.                b7200,b12000,b14400,b16800);
  189. Procedure RSinit (com: integer; speed: RSbaud; buffactor: integer;
  190.                   flow: boolean);
  191.  
  192. The RSInit function is available for users who wish to do all their I/O 
  193. directly through the procedures provided in this unit. You should only use
  194. the RSInit, RSCleanup and SetPortAddress functions if your Door program has
  195. been run in the "None" (no BIOS com support) mode from Searchlight. Do not 
  196. attempt to initialize the modem if BIOS I/O is active!
  197.  
  198. The following parameters are used with the RSInit function:
  199.  
  200.       Com:  Com port number (1-4)
  201.     Speed:  Baud rate (from RSbaud type shown above)
  202. Buffactor:  Output buffering factor (0-32)
  203.      Flow:  Hardware flow control switch
  204.  
  205. You can find the proper values to use for these parameters by examining the 
  206. CONFIG.SL2 file.
  207.  
  208.  
  209. Procedure RSCleanup;         { Reset RS232 port }
  210.  
  211. If you use RSInit to initialize the COM port, you should call RSCleanup to 
  212. de-initialize the port before your program exits.
  213.  
  214.  
  215.  
  216. Var  SLData: ^SLDataType;               { Pointer to public data area }
  217.  
  218. The Searchlight public data area is a block of memory inside the serial port 
  219. drivers which contains variables a Door program may be interested in 
  220. examining. The format of the data area is given by the SLDataType record 
  221. shown below. Variable 'SLData' is automatically initialized as a pointer to 
  222. this data area. (SLData is set to NIL if the public data area is not 
  223. available).  
  224.  
  225. Example:   If SLData<>Nil then begin
  226.              if SLData^.color then writeln('User has a color terminal.');
  227.            end;
  228.  
  229.  
  230. Type AnsiType = (GENERIC,PROCOMM,STANDARD);
  231.  
  232.      SLDataType = record         { Public Data Area }
  233.       PROGID: string[6];                { Contains the string 'SLBBS' }
  234.       carrier: boolean;                 { carrier check enabled? }
  235.       writeprotect: boolean;            { disk write protection? }
  236.       aborttype: byte;                  { 0=no abort, 1=terminate, 2=reboot }
  237.  
  238.       rsact: boolean;                   { set if rs232 active }
  239.       ansi: boolean;                    { is user in ANSI mode? }
  240.       color: boolean;                   { does user have a color crt? }
  241.       directvid: boolean;               { system DirectVideo mode }
  242.  
  243.       curratt: byte;                    { current video attribute }
  244.       commtype: byte;                   { run parameter - used internally }
  245.       idletime: word;                   { idle limit (seconds) }
  246.       lastkey: boolean;                 { TRUE = last key from local kbd }
  247.  
  248.       OldVector: array[$00..$7F] of pointer;   { old user int vectors }
  249.       AnsiMode: AnsiType;               { user's ANSI mode }
  250.      end;
  251.  
  252. Notes:
  253.   The "carrier", "writeprotect" and "aborttype" flags reflect the status of 
  254.   carrier checking and write protection when the door was launched. Changing 
  255.   these flags has no effect.  
  256.  
  257.   The "Rsact" flag is TRUE if the door was launched with BIOS I/O support
  258.   (ie. "Standard" or "Force-Color" type door). It is set to FALSE if the
  259.   door was launched in "None" mode (no modem support) OR if the door was
  260.   run during a local login. (You can examine the CONFIG file to determine
  261.   if the user is local or remote).
  262.  
  263.   You can still use the modem drivers if RSACT is false, but you must 
  264.   initialize the driver with RSInit.
  265.  
  266.   "DirectVid" tells you whether Searchlight is set to allow direct video 
  267.   writes in the CONFIG file.
  268.  
  269.   "LastKey" allows you to determine whether the last keystroke read from 
  270.   standard input originated from the modem or the local keyboard.
  271.  
  272.   "OldVector" stores the saved values of interrupts which Searchlight has
  273.   intercepted. The ComToggle procedure uses these values.
  274.  
  275.   "AnsiMode" returns the ANSI terminal type selected by the user.
  276.  
  277.    Searchlight's active menu stack is also in this memory area. See the 
  278.    sample program "BackTrak" for more information.
  279.  
  280.  
  281.  
  282. The following New Functions are added as of Searchlight 3.0:
  283.  
  284. Function RSVersion: byte;             { Serial unit revision number }
  285.  
  286. This returns the version number of the serial driver unit that is available.
  287. Searchlight 3.0 returns 2 as the version number. Previous versions will
  288. return 0. You should check the version number before performing functions
  289. which are only available in later revisions.
  290.  
  291.  
  292.  
  293. Procedure RS232StrOut (count,strseg,strofs: word);
  294.   { write string to output }
  295.  
  296. This function writes an entire string of data to the serial port instead of
  297. just a character. The maximum string length that may be output is 255. The
  298. inputs correspond to the string length, and the segment and offset of the
  299. first character in the string.
  300.  
  301. The proper way to call this function from Turbo Pascal, assuming "St" is
  302. a string type variable, is:
  303.  
  304.    RS232StrOut(Length(St),Seg(St[1]),Ofs(St[1]));
  305.  
  306. Using RS232StrOut is more efficient than calling RS232Out multiple times, 
  307. since it eliminates multiple interrupt function calls. On standard COM ports
  308. and FOSSIL drivers, Searchlight implements the RS232StrOut function by 
  309. calling the RS232Out function multiple times in a tight assembly language 
  310. loop. With Digiboards, Searchlight calls the Digiboard string output 
  311. function directly, eliminating loop overhead.
  312.  
  313.  
  314. ---------
  315. FL'92/'93
  316.